package com.maozw.api.gateway.config;

import com.maozw.api.gateway.route.DymicRouteLocator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.annotation.Resource;

/**
 * @author MAOZW
 * @Description: ZuulConfig
 * @date 2018/8/10 15:57
 */
@Configuration
public class GatewayZuulConfig {

    @Resource
    ZuulProperties zuulProperties;
    @Resource
    ServerProperties serverProperties;
    @Autowired
    JdbcTemplate jdbcTemplate;


    @Bean
    public DymicRouteLocator routeLocator() {
        DymicRouteLocator routeLocator = new DymicRouteLocator(this.serverProperties.getServletPrefix(), this.zuulProperties);
        routeLocator.setJdbcTemplate(jdbcTemplate);
        return routeLocator;
    }
}
